import device from 'commons/device';
import util from "commons/util";

// url查询参数
const query = util.parseQueryString();


/* eslint-disable */
// 定义环境类型
let defineEnv = __wpdf_define_env__;
// 定义调试模式
let defineDebug = __wpdf_define_debug__;
// 项目页面路径
let publicPagePath = __wpdf_public_page_path__;
// 项目页面名称
let publicPageFullname = __wpdf_public_page_fullname__;
// 项目资源路径
let publicAssetPath = __wpdf_public_asset_path__;
// 后端接口路径
let publicRpcPath = __wpdf_public_rpc_path__;
/* eslint-enable */

// 协议
const agreementViewer = `https://${location.host}/static/pdfjs/web/viewer.html?file=`
const agreementRoot = `https://${location.host}/static/agreement/`;

const agreement = {
  heyjie_goodsbuy: `${agreementViewer}${encodeURIComponent(agreementRoot + 'goodsbuy.pdf')}`,
  heyjie_goodssell: `${agreementViewer}${encodeURIComponent(agreementRoot + 'goodssell.pdf')}`,
  heyjie_userinfo: `${agreementViewer}${encodeURIComponent(agreementRoot + 'userinfo.pdf')}`,
  heyjie_userresgist: `${agreementViewer}${encodeURIComponent(agreementRoot + 'userresgist.pdf')}`,
}

// // 分享内容列表
// const shareTextArr = [
//   {
//     title: "不瞒你说，平时我吃喝玩乐的优惠都在这里买的！",
//     desc: "有福同享！给你介绍一个超便宜的吃喝玩乐代金券商城"
//   },
//   {
//     title: "只需一步，吃喝玩乐可以节省一半！",
//     desc: "拯救花呗，终于找到买买买又省钱的方法了"
//   }
// ];


// // 微信分享索引
// const shareIndex = Math.random() > 0.5 ? 1 : 0;

// 微信分享信息配置
const wechatConfig = {
  // 不允许微信外部环境打开
  notAllowdOutOfWechat: true, //(location.hash.includes("#/ArticleDetail") || query.giocircle) ? false : true,
  appId: location.href.includes("shwzfa.cn") ? "wxaa95f7394b9d14b4":"wx8b520a2904a163d3",
  authorize: location.href.includes("shwzfa.cn") ? "https://api.shwzfa.cn/app/wechat/ajaxAuth" : "https://api.izjut.cn/app/wechat/ajaxAuth",
  useAuthorize: location.href.includes("shwzfa.cn") ? "https://api.shwzfa.cn/app/wechat/authUserInfo" : "https://api.izjut.cn/app/wechat/authUserInfo",
  shareData: {
    title: '比团购还便宜，吃喝玩乐低至1分钱！',
    desc: '出卡啦权益，就是比团购还便宜',
    link: location.href,
    imgUrl: `https://m.shwzfa.cn/static/img/share.png`,
    success: () => { },
    cancel: () => { }
  }
};

// 如果在小程序环境，存储来自小程序的token
let heyjie_token = query.miniprogram_t || localStorage.getItem("heyjie-token");
if (heyjie_token) {
  localStorage.setItem("heyjie-token", heyjie_token);
}


// 默认配置
export default {
  public: { // 部署相关
    defineEnv: defineEnv,
    defineDebug: defineDebug,
    pagePath: publicPagePath,
    pageFullname: publicPageFullname,
    assetPath: publicAssetPath,
    rpcPath: publicRpcPath
  },
  wechat: wechatConfig,
  agreement: agreement,
  miniprogram_t: heyjie_token
};